try:
    from .decorators import instant
    from .zmq_decorators import edp_service_zmq
except ImportError:
    from decorators import instant
    from zmq_decorators import edp_service_zmq

@edp_service_zmq
class TestService:
    name = "test_service"
    desc = "测试服务"
    category = "test"
    tasks = [
        "list_add_1: List<Int>->List<Int>",
        "int_mul_2: Int->Int",
        "long_task: Void->Str"
    ]

    @instant
    def list_add_1(self, inputs):
        res = []
        for each in inputs:
            res.append(each + 1)
        return res
    
    @instant
    def int_mul_2(self, input):
        return input * 2
    
    def long_task(self, inputs):
        import time
        for i in range(5):
            time.sleep(1)
            self.update_progress(i*20 + 20)
            self.log(f'current progress is: {i*20 + 20}%')
            print(f'current progress is: {i*20 + 20}%')
        return "hello edp"

if __name__ == '__main__':
    TestService.run(5018, 5019)